#include <iostream>

#define ok 0
#define MaxSize 100
#define OVERFLOW -1
#define ERROR 1
typedef int status;

#define MAXSIZE 100

using namespace std;

//通过取模，换装增1

typedef struct
{
    int *base;
    int front;
    int rear;

} SqQueue;

//循环队列
status InitQueue(SqQueue &q)
{
    q.base = new int[MAXSIZE];
    if (!q.base)
        exit(1);          //分配失败
    q.front = q.rear = 0; //头指针 尾指针为0，队列为空

    return ok;
}

int QueueLength(SqQueue q)
{

    return (q.rear - q.front + MAXSIZE) % MAXSIZE;
}

status Enqueue(SqQueue &q, int e)
{

    //插入元素e为q的队尾元素
    //堆满
    if (q.rear + 1)%MAXSIZE==0){

        return ERROR
    }
    q.base[q.rear]=e;
    q.rear = (q.rear + 1) % MAXSIZE; //队尾指针+1
    return ok;
}

//出队
status Dequeue(SqQueue &q, int &e)
{
    if (q.front == q.rear)
        return ERROR;
    e = q.base[q.front];
    q.front = (q.front + 1) % MaxSize; //队头指针+1
    return ok;
}

int hethead(SqQueue q)
{

    if (q.front != q.rear)
        return q.base[q.front];
}

//++++++++++++++++++链队+++++++++++++++++++++++++++++++++++++++++++++

typedef struct QNode
{

    int data;
    struct QNode *next;
} QNode, *QueuePtr;

typedef struct
{
    QueuePtr *front;
    QueuePtr *rear;
} LinkQueue;



status InitQ(LinkQueue&q)
{
    q.front=q.rear=new QNode;
    q.front->next=NULL;

    return ok;


}

status Enqueue(LinkQueue&q,int e)
{   
    
    p=new QNode;
    p->data=e;
    p->next=NULL;
    q.rear=p;
    return ok;


}

status Dequeue(LinkQueue&q,int &e)
{

    if(q.front==q.rear)return ERROR;
    p=q.front->next;
    e=p->data;
    q.front->next=p->next;
    if(q.rear==p)q.rear=q.front;
    delete p;
    return ok
}


int getHead(LinkQueue q){

    if(q.front!=q.rear){

        return q.front->next->data;
    }

}

